
package com.xqcx.libra.config;

import com.google.common.collect.Maps;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import java.util.Map;

/**
 * Mq配置信息
 */

@Configuration
@Data
public class MqConfig {

    @Value("${topicPrefix}")
    public String topicPrefix;
    @Value("${tagPrefix}")
    public String tagPrefix;
    @Value("${tableTopics}")
    public String tableTopics;
    @Value("${taskNum}")
    public int taskNum;
    @Value("${nameSrvAddress}")
    public String nameSrvAddress;

    public String suffixProducer = "_producer";
    private static Map<String, String> tableTopic = Maps.newHashMap();

    @PostConstruct
    public void init(){
        if(StringUtils.isBlank(tableTopics)){
            return ;
        }
        String[] split = tableTopics.split("\\u007C");
        for (int i = 0; i < split.length; i++) {
            String s = split[i];
            String[] strings = s.split(",");
            tableTopic.put(strings[0], strings[1]);
        }
    }

    public Map<String, String> getTableTopic(){
        return tableTopic;
    }


}
